<?php

class wgBuildAllLoadTask extends sfPropelBaseTask
{
  protected function configure()
  {
  	$this->addOptions(array(
      new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', 'frontend'),
      new sfCommandOption('with-images', 'i', sfCommandOption::PARAMETER_NONE, 'Do generate images'),
    ));
    
    $this->namespace        = 'wg';
    $this->name             = 'build-all-load';
    $this->briefDescription = 'Among other things';
    $this->detailedDescription = <<<EOF
The [wg:build-all-load|INFO] task does things.
Call it with:

  [php symfony wg:build-all-load|INFO]
EOF;
  }

  protected function execute($arguments = array(), $options = array())
  {
  	
    $buildAll= new sfPropelBuildAllTask($this->dispatcher, $this->formatter);
    $buildAll->setCommandApplication($this->commandApplication);
    $ret = $buildAll->run(array(), array(
    	'--no-confirmation'
    ));
    
    if ($ret != 0) return;
    
    $wgLoadData = new wgReloadTask($this->dispatcher, $this->formatter);
    $wgLoadData->setCommandApplication($this->commandApplication);
    
    $reloadOptions = array();
    if ($options['with-images']) {
    	$reloadOptions[] = 'with-images';
    }
    $wgLoadData->run(array(), $reloadOptions);
    
    $this->cleanup();
    
    return $ret;
  }
}
